/*
 * MainEntryPoint.java
 *
 * Created on May 28, 2008, 8:26 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.wirinun.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import org.wirinun.client.database.DatabaseService;
import org.wirinun.common.Project;

/**
 *
 * @author ETHGGY
 */
public class MainEntryPoint implements EntryPoint {

    /** Creates a new instance of MainEntryPoint */
    public MainEntryPoint() {
    }

    
     public static DatabaseService getService(){
        // Create the client proxy. Note that although you are creating the
        // service interface proper, you cast the result to the asynchronous
        // version of
        // the interface. The cast is always safe because the generated proxy
        // implements the asynchronous interface automatically.
        DatabaseService service = (DatabaseService) GWT.create(DatabaseService.class);
        // Specify the URL at which our service implementation is running.
        // Note that the target URL must reside on the same domain and port from
        // which the host page was served.
        //
        ServiceDefTarget endpoint = (ServiceDefTarget) service;
        String moduleRelativeURL = GWT.getModuleBaseURL() + "database/databaseservice";
        endpoint.setServiceEntryPoint(moduleRelativeURL);
        return service;
    }
    
    
    /** 
        The entry point method, called automatically by loading a module
        that declares an implementing class as an entry-point
    */
    public void onModuleLoad() {
        
        
        
        final Label quoteText = new Label();

        Project[] p = getService().getProjects();

        RootPanel.get().add(quoteText);
        
//         RootPanel.get().add(new GWTServiceUsageExample());
/*
         final Label label = new Label("Hello, Gergo!!!");
        final Button button = new Button("Click me!");
        
        button.addClickListener(new ClickListener(){
            public void onClick(Widget w) {
                label.setVisible(!label.isVisible());
            }
        });
        
        RootPanel.get().add(button);
        RootPanel.get().add(label);
 */
    }

}
